package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.embedded.jetty.ServletContextInitializerConfiguration;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

@RestController
@SpringBootApplication
@EnableWebSecurity
public class DemoWarApplication extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(DemoWarApplication.class);
    }

    @RequestMapping(value = "/show", method = RequestMethod.GET)
    public String show () {
        return "show method";
    }

    public static void main(String[] args) {
        SpringApplication.run(DemoWarApplication.class, args);
    }

    // 登录页，跳转到/templates/login.html页面
    @GetMapping("/login")
    public ModelAndView login() {
        return new ModelAndView("login");
    }

    // 首页，跳转到/templates/index.html页面
    @GetMapping("/index")
    public String index() {
        return "index";
    }

}
